package com.my.controller;


import com.my.DTO.IdDTO;
import com.my.common.core.domain.AjaxResult;
import com.my.domain.*;
import com.my.service.*;
import com.my.vo.PerformanceVo;
import com.my.vo.PressureVo;
import com.my.vo.ThicknessVo;
import com.my.vo.TranslucencyVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("api")
@CrossOrigin(origins = "*")
public class MeiyuanController {


    @Resource
    private MyPaperService myPaperService;

    @Resource
    private MyThicknessDataService myThicknessDataService;

    @Resource
    private MyPressureDataService myPressureDataService;

    @Resource
    private MyTranslucencyService myTranslucencyService;

    @Resource
    private MyPerformanceService myPerformanceService;

    @Resource
    private MyCaseService myCaseService;

    @Resource
    private MyZbzjService myZbzjService;


    /**
     * 获取所有纸张id名称
     *
     * @return
     */
    @GetMapping("/paper")
    public List<MyPaper> paper(String name) {
        return myPaperService.paperDetailList(name);
    }

    /**
     * 编辑纸张
     *
     * @return
     */
    @PostMapping("/paper/edit")
    public AjaxResult paperEdit(@RequestBody MyPaper paper) {
        myPaperService.paperEdit(paper);
        return AjaxResult.success();
    }

    /**
     * 删除纸张
     *
     * @return
     */
    @PostMapping("/paper/deleted")
    public AjaxResult paperDeleted(@RequestBody IdDTO dto) {
        myPaperService.paperDeleted(dto.getId());
        return AjaxResult.success();
    }

    /**
     * 根据纸张id获取纸张厚度
     *
     * @return
     */
    @GetMapping("/thickness")
    public List<List<ThicknessVo>> thicknessList(String id, String name) {
        return myThicknessDataService.thicknessList(id, name);
    }

    /**
     * 纸张厚度编辑
     *
     * @return
     */
    @PostMapping("/thickness/edit")
    public AjaxResult thicknessEdit(@RequestBody MyThicknessData myThicknessData) {
        myThicknessDataService.thicknessEdit(myThicknessData);
        return AjaxResult.success();
    }

    /**
     * 删除纸张厚度数据
     *
     * @return
     */
    @PostMapping("/thickness/deleted")
    public AjaxResult paperThicknessDeleted(@RequestBody IdDTO dto) {
        myThicknessDataService.paperThicknessDeleted(dto.getId());
        return AjaxResult.success();
    }

    /**
     * 根据纸张id获取纸张压力
     *
     * @return
     */
    @GetMapping("/pressure")
    public List<List<PressureVo>> pressureList(String id, String name) {
        return myPressureDataService.pressureList(id, name);
    }

    /**
     * 纸张压力编辑
     *
     * @return
     */
    @PostMapping("/pressure/edit")
    public AjaxResult pressureEdit(@RequestBody MyPressureData myPressureData) {
        myPressureDataService.pressureEdit(myPressureData);
        return AjaxResult.success();
    }

    /**
     * 删除纸张压力数据
     *
     * @return
     */
    @PostMapping("/pressure/deleted")
    public AjaxResult paperPressureDeleted(@RequestBody IdDTO dto) {
        myPressureDataService.paperPressureDeleted(dto.getId());
        return AjaxResult.success();
    }


    /**
     * 根据纸张id获取纸张透光度
     *
     * @return
     */
    @GetMapping("/translucency")
    public List<List<TranslucencyVo>> translucencyList(String id, String name) {
        return myTranslucencyService.translucencyList(id, name);
    }

    /**
     * 纸张透光度编辑
     *
     * @return
     */
    @PostMapping("/translucency/edit")
    public AjaxResult translucencyEdit(@RequestBody MyTranslucency myTranslucency) {
        myTranslucencyService.translucencyEdit(myTranslucency);
        return AjaxResult.success();
    }


    /**
     * 删除纸张透光度数据
     *
     * @return
     */
    @PostMapping("/translucency/deleted")
    public AjaxResult paperTranslucencyDeleted(@RequestBody IdDTO dto) {
        myTranslucencyService.paperTranslucencyDeleted(dto.getId());
        return AjaxResult.success();
    }

    /**
     * 根据纸张id获取纸张详细参数
     *
     * @return
     */
    @GetMapping("/performance")
    public PerformanceVo performanceDetail(String id) {
        return myPerformanceService.performanceDetail(id);
    }

    /**
     * 编辑纸张详细参数
     *
     * @return
     */
    @PostMapping("/performance/edit")
    public AjaxResult performanceEdit(@RequestBody MyPerformance myPerformance) {
        myPerformanceService.performanceEdit(myPerformance);
        return AjaxResult.success();
    }

    /**
     * 删除详细参数
     *
     * @return
     */
    @PostMapping("/performance/deleted")
    public AjaxResult performanceDeleted(@RequestBody IdDTO dto) {
        myPerformanceService.performanceDeleted(dto.getId());
        return AjaxResult.success();
    }

    /**
     * 根据类型id获取艺术案例
     *
     * @return
     */
    @GetMapping("/case")
    public List<MyCase> caseList(Integer id) {
        return myCaseService.caseList(id);
    }

    /**
     * 编辑艺术案例
     *
     * @return
     */
    @PostMapping("/case/edit")
    public AjaxResult caseEdit(@RequestBody MyCase myCase) {
        myCaseService.caseEdit(myCase);
        return AjaxResult.success();
    }

    /**
     * 删除案例数据
     *
     * @return
     */
    @PostMapping("/case/deleted")
    public AjaxResult caseDeleted(@RequestBody IdDTO dto) {
        myCaseService.caseDeleted(dto.getId());
        return AjaxResult.success();
    }


    @GetMapping("/zbzj")
    public List<MyZbzj> zbzjList(String name) {
        return myZbzjService.zbjList(name);
    }

    /**
     * 编辑制备剂
     *
     * @return
     */
    @PostMapping("/zbzj/edit")
    public AjaxResult zbzjEdit(@RequestBody MyZbzj zbzj) {
        myZbzjService.zbzjEdit(zbzj);
        return AjaxResult.success();
    }

    /**
     * 删除制备助剂数据
     *
     * @return
     */
    @PostMapping("/zbzj/deleted")
    public AjaxResult zbzjDeleted(@RequestBody IdDTO dto) {
        myZbzjService.zbzjDeleted(dto.getId());
        return AjaxResult.success();
    }


}



